package com.item1024.filter;

import com.item1024.utils.XssHttpServletRequestWrapper;
import org.apache.log4j.Logger;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author 阳十三
 * @email wdful165177@gmail.com
 * @blog http://www.item1024.com
 * @date 2017/8/4
 */
@WebFilter(filterName = "XssDefenseFilter",urlPatterns = "*.do")
public class XssDefenseFilter implements Filter {
    private static final Logger logger = Logger.getRootLogger();

    FilterConfig filterConfig = null;

        public void init(FilterConfig filterConfig) throws ServletException {

            this.filterConfig=filterConfig;
        }

        public void destroy(){
            this.filterConfig=null;
        }

        public void doFilter(ServletRequest request, ServletResponse response,
                             FilterChain chain)throws IOException,ServletException{
            chain.doFilter(new XssHttpServletRequestWrapper(
                    (HttpServletRequest)request),response);
        }
}
